.row.prepend-top-default
  .col-lg-4.profile-settings-sidebar
    %h4.prepend-top-0
      Pipelines
  .col-lg-8
    = form_for @project, url: project_pipelines_settings_path(@project) do |f|
      %fieldset.builds-feature
        - unless @repository.gitlab_ci_yml
          .form-group
            %p Pipelines need to be configured before you can begin using Continuous Integration.
            = link_to 'Get started with Pipelines', help_page_path('ci/quick_start/README'), class: 'btn btn-info'
            %hr
        .form-group.append-bottom-default
          = f.label :runners_token, "Runner token", class: 'label-light'
          = f.text_field :runners_token, class: "form-control", placeholder: 'xEeFCaDAB89'
          %p.help-block The secure token used by the Runner to checkout the project

        %hr
        .form-group
          %h5.prepend-top-0
            Git strategy for pipelines
          %p
            Choose between <code>clone</code> or <code>fetch</code> to get the recent application code
            = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'git-strategy'), target: '_blank'
          .radio
            = f.label :build_allow_git_fetch_false do
              = f.radio_button :build_allow_git_fetch, 'false'
              %strong git clone
              %br
              %span.descr
                Slower but makes sure the project workspace is pristine as it clones the repository from scratch for every job
          .radio
            = f.label :build_allow_git_fetch_true do
              = f.radio_button :build_allow_git_fetch, 'true'
              %strong git fetch
              %br
              %span.descr
                Faster as it re-uses the project workspace (falling back to clone if it doesn't exist)

        %hr
        .form-group
          = f.label :build_timeout_in_minutes, 'Timeout', class: 'label-light'
          = f.number_field :build_timeout_in_minutes, class: 'form-control', min: '0'
          %p.help-block
            Per job in minutes. If a job passes this threshold, it will be marked as failed
            = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'timeout'), target: '_blank'

        %hr
        .form-group
          .checkbox
            = f.label :public_builds do
              = f.check_box :public_builds
              %strong Public pipelines
            .help-block
              Allow everyone to access pipelines for public and internal projects
              = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'visibility-of-pipelines'), target: '_blank'
        %hr
        .form-group
          .checkbox
            = f.label :auto_cancel_pending_pipelines do
              = f.check_box :auto_cancel_pending_pipelines, {}, 'enabled', 'disabled'
              %strong Auto-cancel redundant, pending pipelines
            .help-block
              New pipelines will cancel older, pending pipelines on the same branch
              = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'auto-cancel-pending-pipelines'), target: '_blank'

        %hr
        .form-group
          = f.label :build_coverage_regex, "Test coverage parsing", class: 'label-light'
          .input-group
            %span.input-group-addon /
            = f.text_field :build_coverage_regex, class: 'form-control', placeholder: 'Regular expression'
            %span.input-group-addon /
          %p.help-block
            A regular expression that will be used to find the test coverage
            output in the job trace. Leave blank to disable
            = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'test-coverage-parsing'), target: '_blank'
          .bs-callout.bs-callout-info
            %p Below are examples of regex for existing tools:
            %ul
              %li
                Simplecov (Ruby) -
                %code \(\d+.\d+\%\) covered
              %li
                pytest-cov (Python) -
                %code \d+\%\s*$
              %li
                phpunit --coverage-text --colors=never (PHP) -
                %code ^\s*Lines:\s*\d+.\d+\%
              %li
                gcovr (C/C++) -
                %code ^TOTAL.*\s+(\d+\%)$
              %li
                tap --coverage-report=text-summary (NodeJS) -
                %code ^Statements\s*:\s*([^%]+)
              %li
                excoveralls (Elixir) -
                %code \[TOTAL\]\s+(\d+\.\d+)%

        = f.submit 'Save changes', class: "btn btn-save"

%hr

.row.prepend-top-default
  = render partial: 'projects/pipelines_settings/badge', collection: @badges
